package com.herui.ota.service.iml;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.herui.ota.dao.mysql.DeviceOtaChannelMapper;
import com.herui.ota.entity.DeviceOtaChannel;
import com.herui.ota.enums.ResponseEnum;
import com.herui.ota.exception.ServiceException;
import com.herui.ota.service.DeviceOtaChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

/**
 * author name: amanda.shan
 * create time: 2024-05-07 14:55:00
 */ 
@Service
public class DeviceOtaChannelServiceIml extends BaseService<DeviceOtaChannelMapper, DeviceOtaChannel> implements DeviceOtaChannelService{

	@Autowired
	@Override
	public void setBaseMapper(DeviceOtaChannelMapper baseMapper) {
		super.setBaseMapper(baseMapper);
	}

	@Override
	public void updateCount(String channel, int count) {
		DeviceOtaChannel deviceOtaChannel = new DeviceOtaChannel();
		deviceOtaChannel.setCount(count);
		update(wrapperEditor(deviceOtaChannel), new QueryWrapper<DeviceOtaChannel>().eq("count", count));
	}

	@Override
	public void save(DeviceOtaChannel entity) {
		checkRight("channel_edit");
		super.save(entity);
	}

	@Override
	public boolean updateById(DeviceOtaChannel entity) {
		checkRight("channel_edit");
		return super.updateById(entity);
	}

	@Override
	public boolean removeById(Serializable id) {
		checkRight("channel_edit");
		return super.removeById(id);
	}

	@Override
	public boolean removeByIds(Collection<? extends Serializable> idList) {
		checkRight("channel_edit");
		return super.removeByIds(idList);
	}
}

